/*
 * @(#)RegistryClientProducer.java
 * Date 2013-04-11
 * Version 1.0
 * Author Jim Horner
 * Copyright (c)2012
 */


package us.hornerscorners.lamppost.repository.inject;

import javax.enterprise.inject.Produces;

import javax.inject.Inject;

import us.hornerscorners.lamppost.ihecommon.config.IHEConfig;
import us.hornerscorners.lamppost.ihecommon.config.IHEServiceType;
import us.hornerscorners.lamppost.ihecommon.config.RepositoryServiceConfig;

import us.hornerscorners.lamppost.registry.client.RegistryClient;

import us.hornerscorners.lamppost.registry.service.AtnaRegistryService;


/**
 *
 * @author jim
 */
public class RegistryClientProducer {

    /** Field description */
    @Inject
    private AtnaRegistryService atnaService;

    /** Field description */
    @Inject
    private IHEConfig config;

    /**
     * Method description
     *
     *
     * @return
     */
    @Produces
    @RepositoryTarget
    public RegistryClient produce() {

        RepositoryServiceConfig repocfg =
            (RepositoryServiceConfig) this.config.findServiceConfig(
                IHEServiceType.Repository);

        return new RegistryClient(
            this.atnaService,
            this.config.findServiceEndpoint(repocfg.getRegistryServiceId()));
    }
}
